<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:pe="http://primefaces.org/ui/extensions">
    <h:form>
        <p:remoteCommand name="adicionarDisciplina" action="#{disciplinaCtrl.adicionarNovaDisciplina()}" update=":frmEdicaoDisciplina" oncomplete="dlgEdicaoDisciplina.show();" />
        <p:remoteCommand name="editarDisciplina" update=":frmEdicaoDisciplina" oncomplete="dlgEdicaoDisciplina.show();" />
    </h:form>
    
    <p:dialog widgetVar="dlgEdicaoDisciplina" closable="false" modal="true" header="Dados da Disciplina" resizable="false" dynamic="true">
        <h:form id="frmEdicaoDisciplina">
            <p:panelGrid columns="2" rendered="#{disciplinaCtrl.disciplina != null}">
                <h:outputLabel value="Código: " />
                <pe:inputNumber value="#{disciplinaCtrl.disciplina.codigo}" decimalPlaces="0" autocomplete="false" required="true" requiredMessage="Informe o código da disciplina" />
                
                <h:outputLabel value="Nome: " />
                <p:inputText value="#{disciplinaCtrl.disciplina.nome}" required="true" requiredMessage="Informe o nome da disciplina" />
                
                <h:outputLabel value="Curso: " />
                <p:selectOneMenu value="#{disciplinaCtrl.disciplina.curso}" required="true" requiredMessage="Selecione o curso ao qual esta disciplina pertence">
                    <f:converter converterId="IndexConverter" />
                    <f:selectItems value="#{disciplinaCtrl.selectCursos}" />
                </p:selectOneMenu>
                
                <h:outputLabel value="Carga Horária Teórica: " />
                <pe:inputNumber value="#{disciplinaCtrl.disciplina.cargaHorariaTeoria}" emptyValue="zero" required="true" requiredMessage="Informe a carga horária teórica da disciplina">
                    <p:ajax event="change" update=":frmEdicaoDisciplina:txtCargaTotal" />
                </pe:inputNumber>
                
                <h:outputLabel value="Carga Horária Prática: " />
                <pe:inputNumber value="#{disciplinaCtrl.disciplina.cargaHorariaPratica}" emptyValue="zero" required="true" requiredMessage="Informa a carga horária prática da disciplina">
                    <p:ajax event="change" update=":frmEdicaoDisciplina:txtCargaTotal" />
                </pe:inputNumber>
                
                <h:outputLabel value="Carga Horária Total:" />
                <h:outputText value="#{disciplinaCtrl.disciplina.cargaHorariaTotal}" id="txtCargaTotal" />
                
                <h:outputLabel value="Ementa: " />
                <p:inputTextarea value="#{disciplinaCtrl.disciplina.ementa}" maxlength="500" cols="50" rows="5" />
            </p:panelGrid>
            
            <p:commandButton action="#{disciplinaCtrl.salvarDisciplina()}" value="Salvar" update=":form-principal :form-sidebar" oncomplete="dlgEdicaoDisciplina.hide();" />
            <p:commandButton action="#{disciplinaCtrl.cancelarEdicao()}" immediate="true" update=":form-principal :form-sidebar" value="Cancelar" oncomplete="dlgEdicaoDisciplina.hide();" />
        </h:form>
    </p:dialog>
</ui:composition>